Class Router

Summary

Fully Qualified Name: CodeIgniter\Router\Router
Implements: RouterInterface

Description

Request router.

Methods

Name Description Defined By
__construct() Stores a reference to the RouteCollection object. Router
autoRoute() Attempts to match a URI path against Controllers and directories found in APPPATH/Controllers, to find a matching route. Router
controllerName() Returns the name of the matched controller. Router
directory() Returns the name of the sub-directory the controller is in, if any. Relative to APPPATH.'Controllers'. Router
get404Override() Returns the 404 Override settings from the Collection. Router
getFilter() Returns the filter info for the matched route, if any. Router
getLocale() Returns the detected locale, if any, or null. Router
getMatchedRoute() Returns the routing information that was matched for this request, if a route was defined. Router
getMatchedRouteOptions() Returns all options set for the matched route Router
handle() Router
hasLocale() Returns true/false based on whether the current route contained a {locale} placeholder. Router
methodName() Returns the name of the method to run in the chosen container. Router
params() Returns the binds that have been matched and collected during the parsing process as an array, ready to send to instance->method(. Router
setDirectory() Sets the sub-directory that the controller is in. Router
setIndexPage() Sets the value that should be used to match the index.php file. Defaults to index.php but this allows you to modify it in case your are using something like mod_rewrite to remove the page. This allows you to set it a blank. Router
setTranslateURIDashes() Tells the system whether we should translate URI dashes or not in the URI from a dash to an underscore. Router

Method Details

__construct()

Stores a reference to the RouteCollection object.

Parameter Name Type Description
$routes \RouteCollectionInterface
$request \Request

Returns:

autoRoute()

Attempts to match a URI path against Controllers and directories found in APPPATH/Controllers, to find a matching route.

Parameter Name Type Description
$uri string

Returns:

controllerName()

Returns the name of the matched controller.

Returns: mixed

directory()

Returns the name of the sub-directory the controller is in, if any. Relative to APPPATH.'Controllers'.

Only used when auto-routing is turned on.

Returns: string

get404Override()

Returns the 404 Override settings from the Collection.

If the override is a string, will split to controller/index array.

Returns:

getFilter()

Returns the filter info for the matched route, if any.

Returns: string

getLocale()

Returns the detected locale, if any, or null.

Returns: string

getMatchedRoute()

Returns the routing information that was matched for this request, if a route was defined.

Returns: array|null

getMatchedRouteOptions()

Returns all options set for the matched route

Returns: array|null

handle()

Parameter Name Type Description
$uri string|null

Returns: mixed|string

hasLocale()

Returns true/false based on whether the current route contained a {locale} placeholder.

Returns: bool

methodName()

Returns the name of the method to run in the chosen container.

Returns: mixed

params()

Returns the binds that have been matched and collected during the parsing process as an array, ready to send to instance->method(.

..$params).

Returns: mixed

setDirectory()

Sets the sub-directory that the controller is in.

Parameter Name Type Description
$dir string|null
$append bool

Returns:

setIndexPage()

Sets the value that should be used to match the index.php file. Defaults to index.php but this allows you to modify it in case your are using something like mod_rewrite to remove the page. This allows you to set it a blank.

Parameter Name Type Description
$page
$page

Returns: mixed

setTranslateURIDashes()

Tells the system whether we should translate URI dashes or not in the URI from a dash to an underscore.

Parameter Name Type Description
$val bool

Returns: $this

Top